<template>
	<view class="wrap safe-area">
		<view class="wrap-list">
			<block v-for="(item, index) in list" :key="index">
				<view class="item flex column">
					<view class="title">
						{{ item.title }}
					</view>
					
					<view class="white-list">
						<block v-for="(subItem, idx) in item.list" :key="idx">
						 	<view class="subItem flex" @click="onItem(subItem)">
								<image class="file" :src="subItem.file" />
								
								<view class="right flex align-center just-between">
									<view class="left flex column">
										<view class="name">
											{{ subItem.title }}
										</view>
										
										<view class="sub-title" v-if="subItem.hasOwnProperty('subTitle')">
											{{ subItem.subTitle }}
										</view>
									</view>
									
									<view class="arrow-box flex align-center">
										<block v-if="subItem.hasOwnProperty('isSwitch')">
											<image class="switch" src="/static/images/switch_on.png" />
										</block>
										
										<block v-else>
											<view class="content">
												{{ subItem.hasOwnProperty("changeKey") && subItem.changeKey === "mobile" ? 
													$filters.onMobileStar(subItem.content) : 
													subItem.content }}
											</view>
											
											<image class="arrow" src="/static/images/arrow_right.png" />
										</block>
									</view>
								</view>
							</view>
						</block>
					</view>
				</view>
			</block>
		</view>
		
		<popupVue
			:isShow.sync="isShowPopup"
			:changeKey="changeKey"
			@onRefresh="onGetUserInfo"
		/>
	</view>
</template>

<script>
	import popupVue from "@/components/popup/popup.vue";
	export default {
		components: {
			popupVue
		},
		data() {
			return {
				userInfo: null, //用户信息
				
				isShowPopup: false,
				changeKey: "",
			};
		},
		computed: {
			list() {
				return [
					{
						title: "账号管理",
						list: [
							{
								file: "/static/images/qhzh.png",
								title: "切换账号",
								content: this.userInfo ? this.userInfo.nickname : "",
								isChange: true,
								changeKey: "nickname",
								isJump: false,
							},
							{
								file: "/static/images/dyh.png",
								title: "抖音号",
								content: this.userInfo ? this.userInfo.dy_num : "",
								changeKey: "dy_num",
								isChange: true,
								isJump: false,
							},
							{
								file: "/static/images/wddym.png",
								title: "我的抖音码",
								content: "",
								isChange: false,
								isJump: false,
							},
							{
								file: "/static/images/sjhbd.png",
								title: "手机号绑定",
								content: this.userInfo ? this.userInfo.mobile : "",
								changeKey: "mobile",
								isChange: true,
								isJump: false,
							},
							{
								file: "/static/images/dymm.png",
								title: "抖音密码",
								content: "已设置",
								isChange: false,
								isJump: false,
							},
							{
								file: "/static/images/dlsbgl.png",
								title: "登录设备管理",
								content: "",
								isChange: false,
								isJump: false,
							},
							{
								file: "/static/images/bcdlxx.png",
								title: "保存登录信息",
								content: "",
								isChange: false,
								isJump: false,
								isSwitch: true,
							},
						]
					},
					{
						title: "绑定与授权",
						list: [
							{
								file: "/static/images/dsfzhbd.png",
								title: "第三方账号绑定",
								content: "",
								isChange: false,
								isJump: false,
							},
							{
								file: "/static/images/sqgl.png",
								title: "授权管理",
								content: "",
								isChange: false,
								isJump: false,
							},
							{
								file: "/static/images/wdhzm.png",
								title: "我的合作码",
								content: "",
								isChange: false,
								isJump: false,
							},
						]
					},
					{
						title: "认证与备案",
						list: [
							{
								title: "实名认证",
								file: "/static/images/smrz.png",
								content: "已认证",
								isChange: false,
								isJump: true,
							},
							{
								title: "申请官方认证",
								file: "/static/images/sqgfrz.png",
								content: "",
								subTitle: "个人、企业机构的账号认证",
								isChange: false,
								isJump: false,
							},
						]
					},
					{
						title: "找回与注销",
						list: [
							{
								title: "找回账号",
								file: "/static/images/find_account.png",
								content: "",
								subTitle: "无法登录其他账号，找回登录",
								isChange: false,
								isJump: false,
							},
							{
								title: "注销账号",
								file: "/static/images/find_account.png",
								content: "",
								isChange: false,
								isJump: false,
							},
							{
								title: "抖音安全中心",
								file: "/static/images/dyaqzx.png",
								content: "",
								subTitle: "包含账号信息泄露、诈骗等账号问题",
								isChange: false,
								isJump: false,
							}
						]
					}
				]
			}
		},
		onShow() {
			this.onGetUserInfo();
		},
		methods: {
			/**
			 * 点击
			 */
			onItem(subItem) {
				if (subItem.isJump) {
					uni.navigateTo({
						url: "/pages/mine/realnameAuth/realnameAuth"
					})
					return;
				}
				if (subItem.isChange) {
					this.changeKey = subItem.changeKey;
					this.isShowPopup = true;
					return;
				}
			},
			
			/**
			 * 获取信息
			 */
			onGetUserInfo() {
				this.userInfo = this.$stoarge.getUserInfo();
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F6F6F6;
	}
	
	.wrap {
		padding-top: 20rpx;
		box-sizing: border-box;
		
		.wrap-list {
			width: 100%;
			overflow: hidden;
			padding: 0rpx 30rpx;
			box-sizing: border-box;
			
			.item {
				width: 100%;
				overflow: hidden;
				gap: 20rpx;
				margin-bottom: 50rpx;
				
				.title {
					margin-left: 20rpx;
					color: #666666;
					font-size: 26rpx;
				}
				
				.white-list {
					width: 100%;
					background-color: white;
					border-radius: 20rpx;
					overflow: hidden;
					
					.subItem {
						width: 100%;
						overflow: hidden;
						padding-top: 40rpx;
						box-sizing: border-box;
						gap: 30rpx;
						
						.file {
							margin-left: 40rpx;
							width: 40rpx;
							height: 40rpx;
						}
						
						.right {
							padding-bottom: 40rpx;
							padding-right: 10rpx;
							flex: 1;
							overflow: hidden;
							gap: 20rpx;
							border-bottom: 2rpx solid #EEEEEE;
							
							.left {
								flex: 1;
								overflow: hidden;
								gap: 20rpx;
								
								.name {
									width: 100%;
									color: #333333;
									font-size: 30rpx;
								}
								
								.sub-title {
									width: 100%;
									color: #999999;
									font-size: 26rpx;
								}
							}
							
							.arrow-box {
								overflow: hidden;
								gap: 20rpx;
								color: #999999;
								font-size: 30rpx;
								
								.switch {
									width: 60rpx;
									height: 30rpx;
								}
								
								.arrow {
									width: 30rpx;
									height: 30rpx;
								}
							}
						}
					}
				}
			}
		}
	}
</style>
